require 'test/unit'
require 't.rb'

#
# Test Configuration
#
class TasksTest < Test::Unit::TestCase
  def test_adding_one_task
    task_manager = TRB::TaskManager.new(task_list: 'test.tasks.json')

    tasks = task_manager.insert('This is a test')

    assert_equal 1, tasks.length
    assert_equal 'This is a test', tasks.first[:task]
  end

  def test_editing_a_task
    task_manager = TRB::TaskManager.new(task_list: 'test.tasks.json')

    tasks = task_manager.insert('This is a test')

    tasks = task_manager.edit(tasks.first[:id], 'This is the real text')

    assert_equal 1, tasks.length
    assert_equal 'This is the real text', tasks.first[:task]
  end

  def test_finishing_a_task
    task_manager = TRB::TaskManager.new(task_list: 'test.tasks.json')

    task_manager.insert('This is a test')
    tasks = task_manager.insert('This is another task')
    tasks = task_manager.finish(tasks.last[:id])

    assert_equal 1, tasks.length
    assert_equal 'This is a test', tasks.first[:task]
  end
end
